home *** CD-ROM | disk | FTP | other *** search
/ PC World 2007 June / PCWorld_2007-06_cd.bin / zabezpeceni / spyeraser / spyeraser.exe / {app} / SpyEraser.dll / 2110 / PHOTOUTILS.JS < prev    next >
Text File  |  2007-04-23  |  1KB  |  46 lines

  1. // correctly handle PNG transparency in Win IE 5.5 & 6.
  2. function handleTransparency()
  3. {
  4.     var b = navigator.appVersion.split("MSIE");
  5.     var v = parseFloat(b[1]);
  6.     if (v >= 5.5 && document.body.filters)
  7.     {
  8.         for(var i=0; i<document.images.length; i++)
  9.         {
  10.             var img = document.images[i];
  11.             var imgName = img.src.toLowerCase();
  12.             if(imgName.substring(imgName.length-3, imgName.length) == "png")
  13.             {
  14.                 var imgID = (img.id) ? "id='"+ img.id +"' " : "";
  15.                 var imgClass = (img.className) ? "class='"+ img.className +"' " : "";
  16.                 var imgTitle = (img.title) ? "title='"+ img.title +"' " : "title='"+ img.alt +"' ";
  17.                 var imgStyle = "display: inline-block;"+ img.style.cssText;
  18.                 
  19.                 switch(img.align)
  20.                 {
  21.                     case "left":
  22.                         imgStyle += "float: left;";
  23.                         break;
  24.                     case "right":
  25.                         imgStyle += "float: right;";
  26.                         break;
  27.                     default:
  28.                         break;
  29.                 }
  30.                 
  31.                 if(img.parentElement.href) imgStyle = "cursor: hand;"+ imgStyle;
  32.                 
  33.                 var strNewHTML = "<span "+ imgID + imgClass + imgTitle
  34.                     +" style=\""+ "width:"+ img.width +"px; height:"+ img.height +"px;"+ imgStyle +";"
  35.                     +"filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
  36.                     +"(src=\'btn_help_selected.png\', sizingMethod='scale');\"></span>";
  37.                 img.outerHTML = strNewHTML;
  38.                 
  39.                 document.write (strNewHTML);
  40.                 alert(strNewHTML);
  41.                 i-=1;
  42.                 
  43.             }
  44.         }
  45.     }    
  46. }